#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

//    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClick);
    MyButton = new QPushButton(this);
    MyButton->setText("你好！");

    connect(MyButton, &QPushButton::clicked, this, &Widget::handleClick);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClick()
{
//    if(ui->pushButton->text() == "你好！")
//    {
//        ui->pushButton->setText("我很好！");
//    }
//    else
//    {
//        ui->pushButton->setText("你好！");
//    }
    if(MyButton->text() == "你好！")
    {
        MyButton->setText("我很好！");
    }
    else
    {
        MyButton->setText("你好！");
    }
}



